#!/bin/bash

#if user has logged in the system 
#then, copy a file to his or her file
#else, display an error information
echo "Type in the user name."
read user
if 
	grep $user /etc/passwd >/tmp/null
	who | grep $user
then echo "$user has logged in the system."
	cp /tmp/null tmp1
	rm /tmp/null
else
	echo "$user has not logged in the system."
fi

if test -f "$1"; then
	echo $1
fi

if [ -f $1 ]; then
	echo $1
fi
# conditional expression 测试文件的属性和进行字符串比较
if [[ -f $1 ]]; then
	echo $1
fi

myfile=if.sh;mydirectory=~

if [[ ! -d $1 ]]; then
	echo NOT
fi

if test -f $myfile -a -r $mydirectory; then 
	echo AND
fi

a=1;b=1
if [ $a -ge 0 -o "$b" -le 0 ]; then
	echo OR
fi

# error,不支持与,或操作 
# a=1;b=1
# if [[ $a -ge 0 -o "$b" -le 0 ]]; then
# 	echo OR
# fi

c=0
if [\( "$a" -gt 0 -o "$b" -lt 0 \) -a "$c" eq 0 ]; then
	echo PARENTHESIS
fi
